<?php
/**
 * 用户表数据操作层
 * @author yangchao
 * @package user
 * @copyright yangchao
 * @version 1.0
 * @code-encode utf-8
 * @data-encode 2011-01-17
 */
define("CACHE_PREFIX_USER","_user_fans_for_search_");
class db_user_fans_for_search extends db_base {
    
	var $table_name = "user_fans_for_search";
	
	function db_user_fans_for_search()
	{
		parent::db_base();
	}
	
	
	function admin_get_one($id)
	{
		$id = intval($id);
		
		$where = "id = $id";
			
		$content = $this->get_alllist($this->table_name,1,1, "", $where);

		return $content[0];
	}
	
	function admin_get_list($status,$p=1,$pcount=10)
	{
		$p = intval($p);
		$pcount = intval($pcount);
		$status = mysql_escape_string($status);
		if(strlen($status)>0)$where_array[] = " status ={$status} ";
		
			
		$where = join(" and ",	$where_array);
		
		$content = $this->get_alllist($this->table_name,$p,$count, " `create_time` desc", $where);
	

		return $content;
	}
	
	function admin_get_count($status)
	{
		$status = mysql_escape_string($status);
		if(strlen($status)>0)$where_array[] = " status ={$status} ";
		
		$where = join(" and ",	$where_array);
		
		$content = $this->get_listcount($this->table_name,$where);
	

		return $content;
	}
	
	
	function admin_insert_user_fans_for_search($uid,$topic_id)
	{
		$ary["uid"] = $uid;
		$ary["topic_id"] = $topic_id;
		$ary["status"] = 1;
		$ary["create_time"] = Date::get_date_time();
		$ary["create_ip"] = IP::get_client_ip_long();
		
		$res = $this->insert($this->table_name,$ary,"",true);
		
		return $res;
		
	}
	
	
	
	function admin_update_by_id($id,$status="",$uid="",$topic_id="")
	{
		$where = "id = $id";
		
		if(strlen($status)>0)$ary["status"] = $status;
		if(strlen($uid)>0)$ary["uid"] = $uid;
		if(strlen($topic_id)>0)$ary["topic_id"] = $topic_id;
		
		
		return $this->update($this->table_name,$ary,$where);
	}
	
	
	
}



